#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
require 'active_record'
puts "Generating CSV at #{RAILS_ROOT}/public/data.csv"
f = File.open(File.join(RAILS_ROOT,'public','data.csv'), 'w+')
attributes = Pilot.column_names - ["id","created_at","updated_at"]
f.puts attributes.join(',')
i = 0
Pilot.all.each do |p|
 print '.'
 i += 1
 values = []
 attributes.each do |a|
   values << p.send(a)
 end
 f.puts values.join(',')
end
f.close
puts "There are #{i} rows."
